package commons;

import java.io.Serializable;

import commons.Status;

/**
 * 
 * Individual Player's status.
 * GAME SPECIFIC For our example game we have a player who can move around.
 *
 */
public class Player extends Status implements Serializable{
	private static final long serialVersionUID = 1L;
	
	private int x;
	private int y;
	private int maxX;
	private int maxY;
	private String name;
	
	public Player(int maxX, int maxY) {
		name = new String("[No name]");
		this.maxX = maxX;
		this.maxY = maxY;
		x = (int) (Math.random() * World.MAX_X);
		y = (int) (Math.random() * World.MAX_Y);
	}
	
	
	public void moveUp() 
	{
		changed();
		y = Math.max(0, y-1);
	}
	
	public void moveDown()
	{
		changed();
		y = Math.min(maxY-1, y+1);
	}
	
	public void moveRight()
	{
		changed();
		x = Math.min(maxX-1, x+1);
	}
	
	public void moveLeft()
	{
		changed();
		x = Math.max(0, x-1);
	}

	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}


	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}
}
